package com.ewhale.feitengguest.presenter.user.task;

import com.ewhale.feitengguest.api.ApiHelper;
import com.ewhale.feitengguest.dto.TaskListDto;
import com.ewhale.feitengguest.view.user.task.TaskListView;
import com.simga.library.base.IPresenter;
import com.simga.library.http.APIException;

import java.util.List;

public class TaskListPresenter extends IPresenter {

    public void getTaskList(int pageNum, int cateId) {
        mView.showProLoading();
        request(1, ApiHelper.TASK_API.getTaskList(pageNum, 20, cateId,3), pageNum);
    }

    @Override
    public <T> void onNext(int postCode, T result, Object data) {
        super.onNext(postCode, result, data);
        switch (postCode) {
            case 1:
                ((TaskListView) mView).showTaskList((List<TaskListDto>) result, (int) data);
                break;
        }
    }

    @Override
    public void otherException(int postCode, Object data, APIException e) {
        super.otherException(postCode, data, e);
        mView.showErrorMessage(postCode, e.getCode(), e.getDisplayMessage());
    }
}
